/*
 * Copyright (c) 2022  by Junzhao
 * THIS FILE IS PART OF JAVASE Song Huongkang PROJECT
 * All Rights Reserved.
 */

package Set;

import org.junit.Test;

import java.util.*;

/**
 * @description LinkedHashSet
 *  作为HashSet的子类
 *  添加时的储存位置仍无序的
 *  但是遍历时按照添加的顺序添加
 *  对于频繁的遍历效率更高
 * @author 俊昭
 * @date 2022/4/19
*/
public class LinkedHashSetTest {
    @Test
    public void text01() {
        Set s1 = new LinkedHashSet();
        s1.add("123");
        s1.add(456);
        s1.add(new User("ZhangSan", 18));
        s1.add(true);
        s1.add(new User("ZhangSan", 18));

        Iterator it1 = s1.iterator();
        while (it1.hasNext()) {
            System.out.println(it1.next());
        }
        /*123
          456
          User{name='ZhangSan', age=18}
          true
         */
    }
}
